﻿using Mathmall.Administration.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Mathmall.Administration.Data
{
    public class SpuImageEntityTypeConfiguration : IEntityTypeConfiguration<SpuImage>
    {
        public void Configure(EntityTypeBuilder<SpuImage> builder)
        {
            // 不使用output子句
            builder.ToTable(table => table.UseSqlOutputClause(false));

            builder
                .ToTable(nameof(SpuImage))
                .ToTable(tableBuilder => tableBuilder.HasComment("spu图片"));

            builder
                .HasKey(spuImage => spuImage.SpuImageID)
                .HasName("SpuImageID");

            builder
                .Property(spuImage => spuImage.SpuID)
                .HasColumnName("SpuID")
                .HasColumnType("int")
                .HasComment("图片名")
                .IsRequired(false);

            builder
                .Property(spuImage => spuImage.ImageName)
                .HasColumnName("ImageName")
                .HasColumnType("nvarchar(200)")
                .HasComment("图片名")
                .IsRequired(false);

            builder
                .Property(spuImage => spuImage.ImageUrl)
                .HasColumnName("ImageUrl")
                .HasColumnType("varchar(255)")
                .HasComment("图片地址")
                .IsRequired(false);

            builder
                .Property(spuImage => spuImage.ImageSort)
                .HasColumnName("ImageSort")
                .HasColumnType("int")
                .HasComment("顺序")
                .IsRequired(false);

            builder
                .Property(spuImage => spuImage.DefaultImage)
                .HasColumnName("DefaultImage")
                .HasColumnType("tinyint")
                .HasComment("是否默认图")
                .IsRequired(false);

            builder
                .Property(spuImage => spuImage.CreateTime)
                .HasColumnName("CreateTime")
                .HasColumnType("datetime")
                .HasComment("创建时间")
                .IsRequired(false);

            builder
                .Property(spuImage => spuImage.LastUpdateTime)
                .HasColumnName("LastUpdateTime")
                .HasColumnType("datetime")
                .HasComment("最后更新时间")
                .IsRequired(false);
        }
    }
}
